{include file="header.html"}
<body class="gr">

<div class="navBar navBar-transparent">
	<a class="left" href="javascript:history.back()"><i class="return"></i></a>
	<div class="titleView"><tt>{$data->city}</tt>-{$data->name}</div>
</div>

<div class="shop-detail width-wrap">
	<div class="pullRefresh">
		<ul class="info">
			<li>
				<div><a href="tel://{$data->mobile}"><i></i>{$data->mobile}</a></div>
				<div><a href="wap.php?app=shop&act=maper&shop_id={$data->id}"><i></i>查看门店地图</a></div>
			</li>
			<li><i></i>近期活动</li>
		</ul>
		<ul class="list">
			{foreach from=$data->ads name=g item=g}
			<li ad_type="{$g->ad_type}" ad_content="{$g->ad_content}" pic="{$g->pic}"></li>
			{/foreach}
		</ul>
	</div>
</div>

{include file="footer.html"}
<script type="text/javascript" src="js/city.js"></script>
<script>
var offset = $('.pullRefresh .list > li').length;
function createHtml(g){
	var html = '<li ad_type="'+g.ad_type+'" ad_content="'+g.ad_content+'" pic="'+g.pic+'"></li>';
	offset++;
	return html;
}
function changeCityCode(){
	$('tt').each(function(){
		var html = $(this).html();
		if(isNaN(html))return true;
		$(this).html(getCityName(html).replace(/市/g, ''));
	});
	setTitleView();
}
$(function(){
	setAds('.list li');
	changeCityCode();
	$('.shop-detail').height($.window().height);
	$('.pullRefresh').pullRefresh({
		header : '<div class="preloader"></div>',
		footer : true,
		footerNoMoreText : '- END -',
		headerView : '<div class="headerView" style="background-image:url({$data->poster_pic});"></div>',
		scroll : function(headerView, headerViewHolder){
			var scrollTop = this.scrollTop(), height = headerViewHolder.height();
			if(scrollTop>=height-$('.navBar').height()){
				$('.navBar').removeClass('navBar-transparent');
				headerView.height(44);
			}else{
				$('.navBar').addClass('navBar-transparent');
				headerView.height(height-scrollTop);
			}
		},
		refresh : function(fn){
			var _this = this;
			offset = 0;
			$.getJSON('api.php?app=shop&act=detail&shop_id={$data->id}', function(json){
				if(json.error!=0){ $.overloadError(json.msg);return }
				var html = '';
				if($.isArray(json.data.ads))for(var i=0; i<json.data.ads.length; i++)html += createHtml(json.data.ads[i]);
				_this.find('.list').html(html);
				setAds('.list li');
				fn();
			});
		},
		load : function(fn){
			var _this = this;
			$.getJSON('api.php?app=shop&act=detail&shop_id={$data->id}', { offset:offset }, function(json){
				if(json.error!=0){ $.overloadError(json.msg);return }
				var html = '';
				if($.isArray(json.data.ads))for(var i=0; i<json.data.ads.length; i++)html += createHtml(json.data.ads[i]);
				_this.find('.list').append(html);
				setAds('.list li');
				fn();
			});
		}
	});
});
</script>